﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace prova
{
    public partial class Form2 : Form
    {

        public Form2()
        {
            InitializeComponent();
        }

        public void setAlumne(Alumne a)
        {
            txtBoxNmatricula.Text = Convert.ToString(a.Nmatricula);
            txtBoxNom.Text = a.Nom;
            txtBoxCognom.Text = a.Cognom;
        }

        private void btnTornar_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnModificar_Click(object sender, EventArgs e)
        {
            txtBoxNom.ReadOnly = false;
            txtBoxCognom.ReadOnly = false;
            btnModificar.Enabled = false;
        }

        private void btnDesar_Click(object sender, EventArgs e)
        {
            AlumneConversor a = new AlumneConversor();
            a.Nmatricula = int.Parse(this.txtBoxNmatricula.Text);
            a.Nom = this.txtBoxNom.Text;
            a.Cognom = this.txtBoxCognom.Text;
            try
            {
                a.update();
                lblCorrecte.Text = "REGISTRE MODIFICAT";
                
            }
            catch (Exception)
            {
                lblCorrecte.Text = "NO S'HA POGUT MODIFICAR EL REGISTRE";
            }
            
        }

    }
}
